<template>
    <div id="pay">
        
    </div>
</template>

<script>
export default {
	asyncData({isDev, route, store, env, params, query, req, res, redirect, error}) {
			// console.log(query)
			return {
				// orderCode: query.c,
				// active: query.a,
				// num: query.n,
				// teamNum: query.t,
				// userId: query.u
			}
	},
    mounted() {
        /** 获取支付参数 */
        const orderCode = this.$route.query.c
        const active = this.$route.query.a
        const num = this.$route.query.n
        const teamNum = this.$route.query.t
        const userId = this.$route.query.u

        var ua = window.navigator.userAgent.toLowerCase();
        //判断是不是微信
        if ( ua.match(/MicroMessenger/i) == 'micromessenger' ) { 
            // alert('即将打开微信支付')
            this.$router.push({path: '/wechat', query: {t: teamNum, c: orderCode, u: userId, n: num, a: active, type: 'wxnativepay'}}) 
            return "wxnativepay"; 
        } else if (ua.match(/AlipayClient/i) == 'alipayclient') {  //判断是不是支付宝
            var params = {
                TeamNum: teamNum,
                OrderCode: orderCode,
                UserID: userId,
                Num: '',
                Action: active,
                PayType: 'alipaydirect'
            }
            this.$router.push({path: '/alipay', query: params})
            return "alipaydirect";  
        }else{   //哪个都不是
            this.$message({
                message: '请用微信或支付宝扫码!'
            })
            return "false";
        }
    }
}
</script>
